package com.xuhuan.thread.study2.proxy;

/**
 * @author huan.xu
 * @date 2021/9/29 9:44
 * @description 静态代理案例：结婚，交给婚庆公司帮忙
 */
public class StaticProxyDemo1 {

    public static void main(String[] args) {
        new MarryCompany(new XiaoHong()).marry();
        new MarryCompany(new XiaoMing()).marry();
    }
}

interface Marry {
    /**
     * 结婚
     */
    void marry();
}

/**
 * 小红
 */
class XiaoHong implements Marry {

    @Override
    public void marry() {
        System.out.println("小红要结婚了。。。");
    }
}

/**
 * 小明
 */
class XiaoMing implements Marry {

    @Override
    public void marry() {
        System.out.println("小明要结婚了。。。");
    }
}

/**
 * 婚庆公司
 */
class MarryCompany implements Marry {

    private Marry marry;

    public MarryCompany(Marry marryOwner) {
        this.marry = marryOwner;
    }

    @Override
    public void marry() {
        this.marry.marry();
    }

}